<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <title>垂直居中的方法2</title>
    <meta content="width=device-width, initial-scale=1.0" name="viewport" user-scalable="no">
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        /*flex法*/
        .father {
            width: 300px;
            height: 200px;
            border: 1px solid black;
            margin: 10px auto;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .child {
            width: 100px;
            height: 100px;
            border: 1px solid red;
        }
    </style>
</head>
<body>
<div class="father">
    <div class="child"></div>
</div>
</body>
</html>
